<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <title>计算属性</title>
</head>
<body>
    <div id="app">
姓氏:<input type="text" v-model="firstname"><br>
名字:<input type="text" v-model="lastname"><br>
全名：{{fullname}}
    </div>
    

    <script>
        new Vue({
            el:"#app",
            data:{
                firstname:"chen",
                lastname:"buer",
                fullname:""
            },
            watch:{
                firstname:function(val){
                    this.fullname=val+" "+this.lastname
                },
                lastname:function(val){
                    this.fullname=this.firstname+" "+val;
                }
            }
        })
    </script>
</body>
</html>